/**
 * @param {number} n
 * @param {number[][]} relation
 * @param {number} k
 * @return {number}
 */
var numWays = function (n, relation, k) {
    const map = new Array(n).fill().map(() => new Array(n).fill(0))
    for (let i = 0; i < relation.length; i++) {
        map[relation[i][0]][relation[i][1]] = 1
    }
    let i = 0, j = 0;
    while (i < n || j < n) {
        if (map[i][j] == 1) {
            i = j
            j = 0
        } else {
            j++
        }
    }
    return map
};
console.log(numWays(5, [[0, 2], [2, 1], [3, 4], [2, 3], [1, 4], [2, 0], [0, 4]]));